import http,{ TokenKey} from './request'
// export const login = (data) => http.getRoot('https://lsebao.com/dev-api/wxLogin',data)
export const login = (data) => http.get('/wxLogin',data)
export const getPhoneNumber = (data) => http.get('/system/user/profile/bindPhonenumber',data)
export const getMe = ()=>http.get('/getInfo')
export async function wxlogin (info) {
  return new Promise((resolve, reject) => {
    uni.login({
      async success (res) {
        const result = await login({ code: res.code });
        uni.setStorageSync(TokenKey,`Bearer ${result.token}`);
        // uni.setStorageSync('session_key',result.session_key);
        if(!result.phone){
          uni.removeStorageSync("user")
        }else{
          
        }
        resolve(result);
      },
      fail (err) {
        reject(err);
      },
    });
  });
}